﻿using System;
using System.Collections.Generic;
using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.DB;
using StairsModuleAndEdit.StairsModel.CommonUnit;
using StairsModuleAndEdit.StairsModel.DataInfos;

namespace StairsModuleAndEdit.StairsModel.Kit
{
	public class EscalatorKit : ProjectionDrawingKit
	{
		public EscalatorKit(Application app) : base(app)
		{
		}

		private List<CurveInfo> DrawRectangleCurves(XYZ ptLftTop, XYZ ptRhtBtm)
		{
			XYZ item = new XYZ(ptLftTop.X, ptRhtBtm.Y, 0.0);
			XYZ item2 = new XYZ(ptRhtBtm.X, ptLftTop.Y, 0.0);
			return base.CreateLoopCurves(new List<XYZ>
			{
				item,
				ptLftTop,
				item2,
				ptRhtBtm
			});
		}

		private void DrawEscalatorRectangelsCurves(ref Escalator stairs)
		{
			int nRunCount = stairs.m_nRunCount;
			LineRunData leftRunData = stairs.m_LeftRunData;
			LineRunData midOneRunData = stairs.m_MidOneRunData;
			LineRunData midTwoRunData = stairs.m_MidTwoRunData;
			LineRunData rightRunData = stairs.m_RightRunData;
			UpStairsType upStairsType = stairs.m_UpStairsType;
			Escalator.PlaceType placeType = stairs.m_PlaceType;
			double dFrontDepth = stairs.m_dFrontDepth;
			double dTreadDepth = stairs.m_dTreadDepth;
			double dStartDepth = stairs.m_dStartDepth;
			switch (nRunCount)
			{
			case 1:
			{
				bool bTurn = EscalatorTurnManger.IsLeftRunNeedTurn(nRunCount, upStairsType, placeType);
				stairs.m_listOtherCurve.AddRange(this.DrawRunAllRectCurves(ref stairs.m_arNoteInfo, leftRunData, dFrontDepth, dTreadDepth, dStartDepth, bTurn));
				return;
			}
			case 2:
			{
				bool bTurn2 = EscalatorTurnManger.IsLeftRunNeedTurn(nRunCount, upStairsType, placeType);
				bool bTurn3 = EscalatorTurnManger.IsMidOneRunNeedTurn(nRunCount, upStairsType, placeType);
				stairs.m_listOtherCurve.AddRange(this.DrawRunAllRectCurves(ref stairs.m_arNoteInfo, leftRunData, dFrontDepth, dTreadDepth, dStartDepth, bTurn2));
				stairs.m_listOtherCurve.AddRange(this.DrawRunAllRectCurves(ref stairs.m_arNoteInfo, midOneRunData, dFrontDepth, dTreadDepth, dStartDepth, bTurn3));
				return;
			}
			case 3:
			{
				bool bTurn4 = EscalatorTurnManger.IsLeftRunNeedTurn(nRunCount, upStairsType, placeType);
				bool bTurn5 = EscalatorTurnManger.IsMidOneRunNeedTurn(nRunCount, upStairsType, placeType);
				bool bTurn6 = EscalatorTurnManger.IsMidTwoRunNeedTurn(nRunCount, upStairsType, placeType);
				stairs.m_listOtherCurve.AddRange(this.DrawRunAllRectCurves(ref stairs.m_arNoteInfo, leftRunData, dFrontDepth, dTreadDepth, dStartDepth, bTurn4));
				stairs.m_listOtherCurve.AddRange(this.DrawRunAllRectCurves(ref stairs.m_arNoteInfo, midOneRunData, dFrontDepth, dTreadDepth, dStartDepth, bTurn5));
				stairs.m_listOtherCurve.AddRange(this.DrawRunAllRectCurves(ref stairs.m_arNoteInfo, midTwoRunData, dFrontDepth, dTreadDepth, dStartDepth, bTurn6));
				return;
			}
			case 4:
			{
				bool bTurn7 = EscalatorTurnManger.IsLeftRunNeedTurn(nRunCount, upStairsType, placeType);
				bool bTurn8 = EscalatorTurnManger.IsMidOneRunNeedTurn(nRunCount, upStairsType, placeType);
				bool bTurn9 = EscalatorTurnManger.IsMidTwoRunNeedTurn(nRunCount, upStairsType, placeType);
				bool bTurn10 = EscalatorTurnManger.IsRightRunNeedTurn(nRunCount, upStairsType, placeType);
				stairs.m_listOtherCurve.AddRange(this.DrawRunAllRectCurves(ref stairs.m_arNoteInfo, leftRunData, dFrontDepth, dTreadDepth, dStartDepth, bTurn7));
				stairs.m_listOtherCurve.AddRange(this.DrawRunAllRectCurves(ref stairs.m_arNoteInfo, midOneRunData, dFrontDepth, dTreadDepth, dStartDepth, bTurn8));
				stairs.m_listOtherCurve.AddRange(this.DrawRunAllRectCurves(ref stairs.m_arNoteInfo, midTwoRunData, dFrontDepth, dTreadDepth, dStartDepth, bTurn9));
				stairs.m_listOtherCurve.AddRange(this.DrawRunAllRectCurves(ref stairs.m_arNoteInfo, rightRunData, dFrontDepth, dTreadDepth, dStartDepth, bTurn10));
				return;
			}
			default:
				return;
			}
		}

		private void DrawUpStairsNoteInfo(ref Escalator stairs)
		{
			List<Escalator.Direction> arDirection = stairs.m_arDirection;
			List<LineRunData> list = new List<LineRunData>();
			list.Add(stairs.m_LeftRunData);
			list.Add(stairs.m_MidOneRunData);
			list.Add(stairs.m_MidTwoRunData);
			list.Add(stairs.m_RightRunData);
			List<UpDownText> list2 = new List<UpDownText>();
			foreach (Escalator.Direction direction in arDirection)
			{
				int nRunIndex = direction.m_nRunIndex;
				LineRunData lineRunData = list[nRunIndex];
				string sText = "上";
				Escalator.PlaceType placeType = stairs.m_PlaceType;
				if (direction.m_bIsReverse)
				{
					sText = "下";
				}
				XYZ xyz = XYZ.BasisY * 1.0;
				XYZ pos = Geometry.CalculatMidPoint(lineRunData.PtRunBottomLeft, lineRunData.PtRunBottomRight) - xyz;
				UpDownText item = new UpDownText(pos, sText);
				list2.Add(item);
			}
			base.DrawUpDownNoteInfo(ref stairs.m_listText, list2);
		}

		private void DrawEscalatorNoteInfo(ref Escalator stairs)
		{
			List<Escalator.NoteData> arNoteInfo = stairs.m_arNoteInfo;
			foreach (Escalator.NoteData noteData in arNoteInfo)
			{
				double num = 0.8;
				bool bIsHori = noteData.m_bIsHori;
				XYZ vecTrans = XYZ.Zero;
				double dBoxWidth;
				double dBoxHeight;
				if (bIsHori)
				{
					vecTrans = XYZ.BasisY;
					dBoxWidth = 5.0;
					dBoxHeight = num * 2.0;
				}
				else
				{
					vecTrans = -XYZ.BasisX;
					dBoxWidth = num * 2.0;
					dBoxHeight = 5.0;
				}
				XYZ ptStart = noteData.m_ptStart;
				XYZ ptEnd = noteData.m_ptEnd;
				string sText = noteData.m_sText;
				base.DrawStairsNoteInfo(ref stairs.m_listOtherCurve, ref stairs.m_listText, ptStart, ptEnd, sText, num, dBoxWidth, dBoxHeight, vecTrans, PenColor.PC_Black);
			}
		}

		private List<CurveInfo> DrawRunAllRectCurves(ref List<Escalator.NoteData> arNoteData, LineRunData runData, double dFrontDepth, double dTreadDepth, double dStartDepth, bool bTurn = false)
		{
			List<CurveInfo> list = new List<CurveInfo>();
			double num = dTreadDepth / 8.0;
			double num2 = dTreadDepth / 2.0;
			XYZ xyz = new XYZ(0.0, num, 0.0);
			XYZ xyz2 = new XYZ(0.0, num2, 0.0);
			XYZ xyz3 = new XYZ(this.m_dRectWidth, 0.0, 0.0);
			XYZ xyz4 = new XYZ(this.m_dOffset, 0.0, 0.0);
			XYZ xyz5 = new XYZ(0.0, dFrontDepth, 0.0);
			XYZ xyz6 = new XYZ(0.0, dTreadDepth, 0.0);
			XYZ xyz7 = new XYZ(0.0, dStartDepth, 0.0);
			if (bTurn)
			{
				Utility.Swap<XYZ>(ref xyz5, ref xyz7);
			}
			XYZ ptLftTop = runData.PtRunTopLeft - xyz3 + xyz5 + xyz;
			XYZ ptRhtBtm = runData.PtRunBottomLeft - xyz7 - xyz;
			list.AddRange(this.DrawRectangleCurves(ptLftTop, ptRhtBtm));
			XYZ ptLftTop2 = runData.PtRunTopLeft - xyz3 * 2.0 + xyz5 + xyz2;
			XYZ ptRhtBtm2 = runData.PtRunBottomLeft - xyz3 - xyz7 - xyz2;
			list.AddRange(this.DrawRectangleCurves(ptLftTop2, ptRhtBtm2));
			XYZ ptLftTop3 = runData.PtRunTopLeft - xyz3 * 3.0 + xyz5 + xyz;
			XYZ ptRhtBtm3 = runData.PtRunBottomLeft - xyz3 * 2.0 - xyz7 - xyz;
			list.AddRange(this.DrawRectangleCurves(ptLftTop3, ptRhtBtm3));
			XYZ ptLftTop4 = runData.PtRunTopRight + xyz5 + xyz;
			XYZ ptRhtBtm4 = runData.PtRunBottomRight + xyz3 - xyz7 - xyz;
			list.AddRange(this.DrawRectangleCurves(ptLftTop4, ptRhtBtm4));
			XYZ ptLftTop5 = runData.PtRunTopRight + xyz3 + xyz5 + xyz2;
			XYZ ptRhtBtm5 = runData.PtRunBottomRight + xyz3 * 2.0 - xyz7 - xyz2;
			list.AddRange(this.DrawRectangleCurves(ptLftTop5, ptRhtBtm5));
			XYZ ptLftTop6 = runData.PtRunTopRight + xyz3 * 2.0 + xyz5 + xyz;
			XYZ ptRhtBtm6 = runData.PtRunBottomRight + xyz3 * 3.0 - xyz7 - xyz;
			list.AddRange(this.DrawRectangleCurves(ptLftTop6, ptRhtBtm6));
			XYZ xyz8 = runData.PtRunTopLeft + xyz5;
			XYZ ptRunTopRight = runData.PtRunTopRight;
			list.AddRange(this.DrawRectangleCurves(xyz8, ptRunTopRight));
			XYZ ptRunBottomLeft = runData.PtRunBottomLeft;
			XYZ xyz9 = runData.PtRunBottomRight - xyz7;
			list.AddRange(this.DrawRectangleCurves(ptRunBottomLeft, xyz9));
			XYZ xyz10 = runData.PtRunTopLeft - xyz3 * 3.0 - xyz4 + xyz5 + xyz6;
			XYZ xyz11 = runData.PtRunBottomRight + xyz3 * 3.0 + xyz4 - xyz7 - xyz6;
			list.AddRange(this.DrawRectangleCurves(xyz10, xyz11));
			if (arNoteData.Count == 0)
			{
				XYZ xyz12 = -XYZ.BasisX * (this.m_dRectWidth + this.m_dOffset + 1.0);
				XYZ xyz13 = XYZ.BasisY * (dTreadDepth + 0.5);
				double num3 = 2.0;
				double num4 = num3 + 1.0;
				double num5 = num4;
				double num6 = num5 + num3;
				double num7 = num6 + num3;
				XYZ xyz14 = ptRunBottomLeft;
				XYZ xyz15 = new XYZ(ptRunBottomLeft.X, xyz9.Y, 0.0);
				XYZ xyz16 = xyz8;
				XYZ xyz17 = new XYZ(xyz8.X, ptRunTopRight.Y, 0.0);
				string sText = "起步进深";
				if (bTurn)
				{
					sText = "前沿进深";
				}
				XYZ ptS = xyz14 + xyz12 * num4;
				XYZ ptE = xyz15 + xyz12 * num4;
				Escalator.NoteData item = new Escalator.NoteData(ptS, ptE, sText, false);
				arNoteData.Add(item);
				XYZ xyz18 = xyz15 + xyz12 * num6;
				XYZ ptE2 = xyz18 - xyz6;
				sText = "踏板进深";
				item = new Escalator.NoteData(xyz18, ptE2, sText, false);
				arNoteData.Add(item);
				XYZ ptS2 = xyz17 + xyz12;
				XYZ ptE3 = xyz14 + xyz12;
				sText = "梯级长度";
				item = new Escalator.NoteData(ptS2, ptE3, sText, false);
				arNoteData.Add(item);
				XYZ ptS3 = xyz16 + xyz12 * num5;
				XYZ ptE4 = xyz17 + xyz12 * num5;
				sText = "前沿进深";
				if (bTurn)
				{
					sText = "起步进深";
				}
				item = new Escalator.NoteData(ptS3, ptE4, sText, false);
				arNoteData.Add(item);
				XYZ xyz19 = xyz16 + xyz12 * num6;
				XYZ ptE5 = xyz19 + xyz6;
				sText = "踏板进深";
				item = new Escalator.NoteData(xyz19, ptE5, sText, false);
				arNoteData.Add(item);
				XYZ ptS4 = xyz10 + xyz12 * num7;
				XYZ ptE6 = new XYZ(xyz10.X, xyz11.Y, 0.0) + xyz12 * num7;
				sText = "水平跨度";
				item = new Escalator.NoteData(ptS4, ptE6, sText, false);
				arNoteData.Add(item);
				XYZ ptS5 = xyz16 + xyz13;
				XYZ ptE7 = new XYZ(ptRunTopRight.X, xyz16.Y, 0.0) + xyz13;
				sText = "梯级宽度";
				item = new Escalator.NoteData(ptS5, ptE7, sText, true);
				arNoteData.Add(item);
			}
			return list;
		}

		private void TranslationPoints(LineRunData runData, XYZ vecTrans)
		{
			runData.PtRunBottomLeft += vecTrans;
			runData.PtRunBottomRight += vecTrans;
			runData.PtRunTopLeft += vecTrans;
			runData.PtRunTopRight += vecTrans;
		}

		private void CalcStairsRunsOriginPoints(ref Escalator stairs)
		{
			LineRunData leftRunData = stairs.m_LeftRunData;
			LineRunData midOneRunData = stairs.m_MidOneRunData;
			LineRunData midTwoRunData = stairs.m_MidTwoRunData;
			LineRunData rightRunData = stairs.m_RightRunData;
			int nRunCount = stairs.m_nRunCount;
			UpStairsType upStairsType = stairs.m_UpStairsType;
			Escalator.PlaceType placeType = stairs.m_PlaceType;
			double dStairsDis = stairs.m_dStairsDis;
			double runWidth = leftRunData.RunWidth;
			double runLength = leftRunData.RunLength;
			double num = dStairsDis + (3.0 * this.m_dRectWidth + this.m_dOffset) * 2.0;
			XYZ xyz = new XYZ(num, 0.0, 0.0);
			XYZ xyz2 = new XYZ(runWidth, 0.0, 0.0);
			XYZ xyz3 = new XYZ(0.0, runLength, 0.0);
			XYZ xyz4 = new XYZ(0.0, 0.0, 0.0);
			XYZ ptRunTopLeft = xyz4 + xyz3;
			XYZ xyz5 = xyz4 + xyz2;
			XYZ ptRunTopRight = xyz5 + xyz3;
			XYZ xyz6 = xyz5 + xyz;
			XYZ ptRunTopLeft2 = xyz6 + xyz3;
			XYZ xyz7 = xyz6 + xyz2;
			XYZ ptRunTopRight2 = xyz7 + xyz3;
			XYZ xyz8 = xyz7 + xyz;
			XYZ ptRunTopLeft3 = xyz8 + xyz3;
			XYZ xyz9 = xyz8 + xyz2;
			XYZ ptRunTopRight3 = xyz9 + xyz3;
			XYZ xyz10 = xyz9 + xyz;
			XYZ ptRunTopLeft4 = xyz10 + xyz3;
			XYZ xyz11 = xyz10 + xyz2;
			XYZ ptRunTopRight4 = xyz11 + xyz3;
			stairs.m_LeftRunData.PtRunBottomLeft = xyz4;
			stairs.m_LeftRunData.PtRunBottomRight = xyz5;
			stairs.m_LeftRunData.PtRunTopLeft = ptRunTopLeft;
			stairs.m_LeftRunData.PtRunTopRight = ptRunTopRight;
			stairs.m_MidOneRunData.PtRunBottomLeft = xyz6;
			stairs.m_MidOneRunData.PtRunBottomRight = xyz7;
			stairs.m_MidOneRunData.PtRunTopLeft = ptRunTopLeft2;
			stairs.m_MidOneRunData.PtRunTopRight = ptRunTopRight2;
			stairs.m_MidTwoRunData.PtRunBottomLeft = xyz8;
			stairs.m_MidTwoRunData.PtRunBottomRight = xyz9;
			stairs.m_MidTwoRunData.PtRunTopLeft = ptRunTopLeft3;
			stairs.m_MidTwoRunData.PtRunTopRight = ptRunTopRight3;
			stairs.m_RightRunData.PtRunBottomLeft = xyz10;
			stairs.m_RightRunData.PtRunBottomRight = xyz11;
			stairs.m_RightRunData.PtRunTopLeft = ptRunTopLeft4;
			stairs.m_RightRunData.PtRunTopRight = ptRunTopRight4;
			double dFrontDepth = stairs.m_dFrontDepth;
			double dStartDepth = stairs.m_dStartDepth;
			XYZ xyz12 = new XYZ(0.0, dFrontDepth, 0.0);
			XYZ xyz13 = new XYZ(0.0, dStartDepth, 0.0);
			XYZ vecTrans = xyz12 - xyz13;
			if (EscalatorTurnManger.IsLeftRunNeedTurn(nRunCount, upStairsType, placeType))
			{
				this.TranslationPoints(leftRunData, vecTrans);
			}
			if (EscalatorTurnManger.IsMidOneRunNeedTurn(nRunCount, upStairsType, placeType))
			{
				this.TranslationPoints(midOneRunData, vecTrans);
			}
			if (EscalatorTurnManger.IsMidTwoRunNeedTurn(nRunCount, upStairsType, placeType))
			{
				this.TranslationPoints(midTwoRunData, vecTrans);
			}
			if (EscalatorTurnManger.IsRightRunNeedTurn(nRunCount, upStairsType, placeType))
			{
				this.TranslationPoints(rightRunData, vecTrans);
			}
		}

		private List<XYZ> CalcStairsInsertPoints(ref Escalator stairs, ref double dCountWidth, ref double dCountLength, double dFrontDepth, double dTreadDepth, double dStartDepth)
		{
			List<XYZ> list = new List<XYZ>();
			int nRunCount = stairs.m_nRunCount;
			LineRunData leftRunData = stairs.m_LeftRunData;
			LineRunData midOneRunData = stairs.m_MidOneRunData;
			LineRunData midTwoRunData = stairs.m_MidTwoRunData;
			LineRunData rightRunData = stairs.m_RightRunData;
			UpStairsType upStairsType = stairs.m_UpStairsType;
			Escalator.PlaceType placeType = stairs.m_PlaceType;
			double num = (3.0 * this.m_dRectWidth + this.m_dOffset) * 2.0 + leftRunData.RunWidth;
			double dStairsDis = stairs.m_dStairsDis;
			XYZ xyz = new XYZ(this.m_dRectWidth, 0.0, 0.0);
			XYZ xyz2 = new XYZ(this.m_dOffset, 0.0, 0.0);
			XYZ xyz3 = new XYZ(0.0, dFrontDepth, 0.0);
			XYZ xyz4 = new XYZ(0.0, dTreadDepth, 0.0);
			XYZ xyz5 = new XYZ(0.0, dStartDepth, 0.0);
			if (EscalatorTurnManger.IsLeftRunNeedTurn(nRunCount, upStairsType, placeType))
			{
				Utility.Swap<XYZ>(ref xyz3, ref xyz5);
			}
			XYZ xyz6 = new XYZ(num, 0.0, 0.0);
			XYZ xyz7 = new XYZ(dStairsDis, 0.0, 0.0);
			XYZ xyz8 = leftRunData.PtRunTopLeft - xyz * 3.0 - xyz2 + xyz3 + xyz4;
			XYZ xyz9 = leftRunData.PtRunBottomLeft - xyz * 3.0 - xyz2 - xyz5 - xyz4;
			list.Add(xyz9);
			list.Add(xyz8);
			dCountLength = xyz8.DistanceTo(xyz9);
			switch (nRunCount)
			{
			case 1:
			{
				XYZ xyz10 = xyz8 + xyz6;
				XYZ item = xyz9 + xyz6;
				list.Add(xyz10);
				list.Add(item);
				dCountWidth = xyz8.DistanceTo(xyz10);
				break;
			}
			case 2:
			{
				XYZ xyz11 = xyz8 + xyz6 * 2.0 + xyz7;
				XYZ item2 = xyz9 + xyz6 * 2.0 + xyz7;
				list.Add(xyz11);
				list.Add(item2);
				dCountWidth = xyz8.DistanceTo(xyz11);
				break;
			}
			case 3:
			{
				XYZ xyz12 = xyz8 + xyz6 * 3.0 + xyz7 * 2.0;
				XYZ item3 = xyz9 + xyz6 * 3.0 + xyz7 * 2.0;
				list.Add(xyz12);
				list.Add(item3);
				dCountWidth = xyz8.DistanceTo(xyz12);
				break;
			}
			case 4:
			{
				XYZ xyz13 = xyz8 + xyz6 * 4.0 + xyz7 * 3.0;
				XYZ item4 = xyz9 + xyz6 * 4.0 + xyz7 * 3.0;
				list.Add(xyz13);
				list.Add(item4);
				dCountWidth = xyz8.DistanceTo(xyz13);
				break;
			}
			}
			return list;
		}

		private void DrawTwoRunCurves(ref Escalator param_stairs)
		{
			LineRunData leftRunData = param_stairs.m_LeftRunData;
			LineRunData midOneRunData = param_stairs.m_MidOneRunData;
			int nRunCount = param_stairs.m_nRunCount;
			UpStairsType upStairsType = param_stairs.m_UpStairsType;
			Escalator.PlaceType placeType = param_stairs.m_PlaceType;
			bool bNoteUpStairs = param_stairs.m_bNoteUpStairs;
			XYZ ptRunBottomLeft = leftRunData.PtRunBottomLeft;
			XYZ ptRunBottomRight = leftRunData.PtRunBottomRight;
			XYZ ptRunTopRight = leftRunData.PtRunTopRight;
			XYZ ptRunTopLeft = leftRunData.PtRunTopLeft;
			XYZ ptRunBottomLeft2 = midOneRunData.PtRunBottomLeft;
			XYZ ptRunBottomRight2 = midOneRunData.PtRunBottomRight;
			XYZ ptRunTopRight2 = midOneRunData.PtRunTopRight;
			XYZ ptRunTopLeft2 = midOneRunData.PtRunTopLeft;
			if (EscalatorTurnManger.IsLeftRunDirectNeedTurn(nRunCount, upStairsType, placeType))
			{
				Escalator.Direction item = new Escalator.Direction(0, true);
				param_stairs.m_arDirection.Add(item);
				Utility.Swap<XYZ>(ref ptRunBottomLeft, ref ptRunTopRight);
				Utility.Swap<XYZ>(ref ptRunBottomRight, ref ptRunTopLeft);
			}
			else
			{
				Escalator.Direction item2 = new Escalator.Direction(0, false);
				param_stairs.m_arDirection.Add(item2);
			}
			if (EscalatorTurnManger.IsMidOneRunDirectNeedTurn(nRunCount, upStairsType, placeType))
			{
				Escalator.Direction item3 = new Escalator.Direction(1, true);
				param_stairs.m_arDirection.Add(item3);
				Utility.Swap<XYZ>(ref ptRunBottomLeft2, ref ptRunTopRight2);
				Utility.Swap<XYZ>(ref ptRunBottomRight2, ref ptRunTopLeft2);
			}
			else
			{
				Escalator.Direction item4 = new Escalator.Direction(1, false);
				param_stairs.m_arDirection.Add(item4);
			}
			SingleRunCurveInfo singleRunCurveInfo = new SingleRunCurveInfo();
			singleRunCurveInfo.BottomElevation = leftRunData.BottomElevation;
			base.DrawLinearRun(leftRunData, ptRunBottomLeft, ptRunBottomRight, ptRunTopRight, ptRunTopLeft, ref singleRunCurveInfo, ref param_stairs.m_listOtherCurve, bNoteUpStairs);
			param_stairs.m_listRunCurve.Add(singleRunCurveInfo);
			singleRunCurveInfo = new SingleRunCurveInfo();
			singleRunCurveInfo.BottomElevation = leftRunData.BottomElevation;
			base.DrawLinearRun(midOneRunData, ptRunBottomLeft2, ptRunBottomRight2, ptRunTopRight2, ptRunTopLeft2, ref singleRunCurveInfo, ref param_stairs.m_listOtherCurve, bNoteUpStairs);
			param_stairs.m_listRunCurve.Add(singleRunCurveInfo);
		}

		private void DrawThreeRunCurves(ref Escalator param_stairs)
		{
			LineRunData leftRunData = param_stairs.m_LeftRunData;
			LineRunData midOneRunData = param_stairs.m_MidOneRunData;
			LineRunData midTwoRunData = param_stairs.m_MidTwoRunData;
			int nRunCount = param_stairs.m_nRunCount;
			UpStairsType upStairsType = param_stairs.m_UpStairsType;
			Escalator.PlaceType placeType = param_stairs.m_PlaceType;
			bool bNoteUpStairs = param_stairs.m_bNoteUpStairs;
			XYZ ptRunBottomLeft = leftRunData.PtRunBottomLeft;
			XYZ ptRunBottomRight = leftRunData.PtRunBottomRight;
			XYZ ptRunTopRight = leftRunData.PtRunTopRight;
			XYZ ptRunTopLeft = leftRunData.PtRunTopLeft;
			XYZ ptRunBottomLeft2 = midOneRunData.PtRunBottomLeft;
			XYZ ptRunBottomRight2 = midOneRunData.PtRunBottomRight;
			XYZ ptRunTopRight2 = midOneRunData.PtRunTopRight;
			XYZ ptRunTopLeft2 = midOneRunData.PtRunTopLeft;
			XYZ ptRunBottomLeft3 = midTwoRunData.PtRunBottomLeft;
			XYZ ptRunBottomRight3 = midTwoRunData.PtRunBottomRight;
			XYZ ptRunTopRight3 = midTwoRunData.PtRunTopRight;
			XYZ ptRunTopLeft3 = midTwoRunData.PtRunTopLeft;
			if (EscalatorTurnManger.IsLeftRunDirectNeedTurn(nRunCount, upStairsType, placeType))
			{
				Escalator.Direction item = new Escalator.Direction(0, true);
				param_stairs.m_arDirection.Add(item);
				Utility.Swap<XYZ>(ref ptRunBottomLeft, ref ptRunTopRight);
				Utility.Swap<XYZ>(ref ptRunBottomRight, ref ptRunTopLeft);
			}
			else
			{
				Escalator.Direction item2 = new Escalator.Direction(0, false);
				param_stairs.m_arDirection.Add(item2);
			}
			if (EscalatorTurnManger.IsMidOneRunDirectNeedTurn(nRunCount, upStairsType, placeType))
			{
				Escalator.Direction item3 = new Escalator.Direction(1, true);
				param_stairs.m_arDirection.Add(item3);
				Utility.Swap<XYZ>(ref ptRunBottomLeft2, ref ptRunTopRight2);
				Utility.Swap<XYZ>(ref ptRunBottomRight2, ref ptRunTopLeft2);
			}
			else
			{
				Escalator.Direction item4 = new Escalator.Direction(1, false);
				param_stairs.m_arDirection.Add(item4);
			}
			if (EscalatorTurnManger.IsMidTwoRunDirectNeedTurn(nRunCount, upStairsType, placeType))
			{
				Escalator.Direction item5 = new Escalator.Direction(2, true);
				param_stairs.m_arDirection.Add(item5);
				Utility.Swap<XYZ>(ref ptRunBottomLeft3, ref ptRunTopRight3);
				Utility.Swap<XYZ>(ref ptRunBottomRight3, ref ptRunTopLeft3);
			}
			else
			{
				Escalator.Direction item6 = new Escalator.Direction(2, false);
				param_stairs.m_arDirection.Add(item6);
			}
			SingleRunCurveInfo singleRunCurveInfo = new SingleRunCurveInfo();
			singleRunCurveInfo.BottomElevation = leftRunData.BottomElevation;
			base.DrawLinearRun(leftRunData, ptRunBottomLeft, ptRunBottomRight, ptRunTopRight, ptRunTopLeft, ref singleRunCurveInfo, ref param_stairs.m_listOtherCurve, bNoteUpStairs);
			param_stairs.m_listRunCurve.Add(singleRunCurveInfo);
			singleRunCurveInfo = new SingleRunCurveInfo();
			singleRunCurveInfo.BottomElevation = midOneRunData.BottomElevation;
			base.DrawLinearRun(midOneRunData, ptRunBottomLeft2, ptRunBottomRight2, ptRunTopRight2, ptRunTopLeft2, ref singleRunCurveInfo, ref param_stairs.m_listOtherCurve, bNoteUpStairs);
			param_stairs.m_listRunCurve.Add(singleRunCurveInfo);
			singleRunCurveInfo = new SingleRunCurveInfo();
			singleRunCurveInfo.BottomElevation = midTwoRunData.BottomElevation;
			base.DrawLinearRun(midTwoRunData, ptRunBottomLeft3, ptRunBottomRight3, ptRunTopRight3, ptRunTopLeft3, ref singleRunCurveInfo, ref param_stairs.m_listOtherCurve, bNoteUpStairs);
			param_stairs.m_listRunCurve.Add(singleRunCurveInfo);
		}

		private void DrawFourRunCurves(ref Escalator param_stairs)
		{
			LineRunData leftRunData = param_stairs.m_LeftRunData;
			LineRunData midOneRunData = param_stairs.m_MidOneRunData;
			LineRunData midTwoRunData = param_stairs.m_MidTwoRunData;
			LineRunData rightRunData = param_stairs.m_RightRunData;
			int nRunCount = param_stairs.m_nRunCount;
			UpStairsType upStairsType = param_stairs.m_UpStairsType;
			Escalator.PlaceType placeType = param_stairs.m_PlaceType;
			bool bNoteUpStairs = param_stairs.m_bNoteUpStairs;
			XYZ ptRunBottomLeft = leftRunData.PtRunBottomLeft;
			XYZ ptRunBottomRight = leftRunData.PtRunBottomRight;
			XYZ ptRunTopRight = leftRunData.PtRunTopRight;
			XYZ ptRunTopLeft = leftRunData.PtRunTopLeft;
			XYZ ptRunBottomLeft2 = midOneRunData.PtRunBottomLeft;
			XYZ ptRunBottomRight2 = midOneRunData.PtRunBottomRight;
			XYZ ptRunTopRight2 = midOneRunData.PtRunTopRight;
			XYZ ptRunTopLeft2 = midOneRunData.PtRunTopLeft;
			XYZ ptRunBottomLeft3 = midTwoRunData.PtRunBottomLeft;
			XYZ ptRunBottomRight3 = midTwoRunData.PtRunBottomRight;
			XYZ ptRunTopRight3 = midTwoRunData.PtRunTopRight;
			XYZ ptRunTopLeft3 = midTwoRunData.PtRunTopLeft;
			XYZ ptRunBottomLeft4 = rightRunData.PtRunBottomLeft;
			XYZ ptRunBottomRight4 = rightRunData.PtRunBottomRight;
			XYZ ptRunTopRight4 = rightRunData.PtRunTopRight;
			XYZ ptRunTopLeft4 = rightRunData.PtRunTopLeft;
			if (EscalatorTurnManger.IsLeftRunDirectNeedTurn(nRunCount, upStairsType, placeType))
			{
				Escalator.Direction item = new Escalator.Direction(0, true);
				param_stairs.m_arDirection.Add(item);
				Utility.Swap<XYZ>(ref ptRunBottomLeft, ref ptRunTopRight);
				Utility.Swap<XYZ>(ref ptRunBottomRight, ref ptRunTopLeft);
			}
			else
			{
				Escalator.Direction item2 = new Escalator.Direction(0, false);
				param_stairs.m_arDirection.Add(item2);
			}
			if (EscalatorTurnManger.IsMidOneRunDirectNeedTurn(nRunCount, upStairsType, placeType))
			{
				Escalator.Direction item3 = new Escalator.Direction(1, true);
				param_stairs.m_arDirection.Add(item3);
				Utility.Swap<XYZ>(ref ptRunBottomLeft2, ref ptRunTopRight2);
				Utility.Swap<XYZ>(ref ptRunBottomRight2, ref ptRunTopLeft2);
			}
			else
			{
				Escalator.Direction item4 = new Escalator.Direction(1, false);
				param_stairs.m_arDirection.Add(item4);
			}
			if (EscalatorTurnManger.IsMidTwoRunDirectNeedTurn(nRunCount, upStairsType, placeType))
			{
				Escalator.Direction item5 = new Escalator.Direction(2, true);
				param_stairs.m_arDirection.Add(item5);
				Utility.Swap<XYZ>(ref ptRunBottomLeft3, ref ptRunTopRight3);
				Utility.Swap<XYZ>(ref ptRunBottomRight3, ref ptRunTopLeft3);
			}
			else
			{
				Escalator.Direction item6 = new Escalator.Direction(2, false);
				param_stairs.m_arDirection.Add(item6);
			}
			if (EscalatorTurnManger.IsRightRunDirectNeedTurn(nRunCount, upStairsType, placeType))
			{
				Escalator.Direction item7 = new Escalator.Direction(3, true);
				param_stairs.m_arDirection.Add(item7);
				Utility.Swap<XYZ>(ref ptRunBottomLeft4, ref ptRunTopRight4);
				Utility.Swap<XYZ>(ref ptRunBottomRight4, ref ptRunTopLeft4);
			}
			else
			{
				Escalator.Direction item8 = new Escalator.Direction(3, false);
				param_stairs.m_arDirection.Add(item8);
			}
			SingleRunCurveInfo singleRunCurveInfo = new SingleRunCurveInfo();
			singleRunCurveInfo.BottomElevation = leftRunData.BottomElevation;
			base.DrawLinearRun(leftRunData, ptRunBottomLeft, ptRunBottomRight, ptRunTopRight, ptRunTopLeft, ref singleRunCurveInfo, ref param_stairs.m_listOtherCurve, bNoteUpStairs);
			param_stairs.m_listRunCurve.Add(singleRunCurveInfo);
			singleRunCurveInfo = new SingleRunCurveInfo();
			singleRunCurveInfo.BottomElevation = midOneRunData.BottomElevation;
			base.DrawLinearRun(midOneRunData, ptRunBottomLeft2, ptRunBottomRight2, ptRunTopRight2, ptRunTopLeft2, ref singleRunCurveInfo, ref param_stairs.m_listOtherCurve, bNoteUpStairs);
			param_stairs.m_listRunCurve.Add(singleRunCurveInfo);
			singleRunCurveInfo = new SingleRunCurveInfo();
			singleRunCurveInfo.BottomElevation = midTwoRunData.BottomElevation;
			base.DrawLinearRun(midTwoRunData, ptRunBottomLeft3, ptRunBottomRight3, ptRunTopRight3, ptRunTopLeft3, ref singleRunCurveInfo, ref param_stairs.m_listOtherCurve, bNoteUpStairs);
			param_stairs.m_listRunCurve.Add(singleRunCurveInfo);
			singleRunCurveInfo = new SingleRunCurveInfo();
			singleRunCurveInfo.BottomElevation = rightRunData.BottomElevation;
			base.DrawLinearRun(rightRunData, ptRunBottomLeft4, ptRunBottomRight4, ptRunTopRight4, ptRunTopLeft4, ref singleRunCurveInfo, ref param_stairs.m_listOtherCurve, bNoteUpStairs);
			param_stairs.m_listRunCurve.Add(singleRunCurveInfo);
		}

		private void GetSingleRunCurveInfo(ref List<CurveInfo> arCurves, SingleRunCurveInfo runCurve)
		{
			arCurves.AddRange(runCurve.RunBoundaryCurvesInfoList);
			arCurves.AddRange(runCurve.RunRiserCurvesInfoList);
			arCurves.AddRange(runCurve.RunPathCurvesInfoList);
		}

		private void DrawEscalatorRunCurves(ref Escalator param_stairs)
		{
			LineRunData leftRunData = param_stairs.m_LeftRunData;
			LineRunData midOneRunData = param_stairs.m_MidOneRunData;
			LineRunData midTwoRunData = param_stairs.m_MidTwoRunData;
			LineRunData rightRunData = param_stairs.m_RightRunData;
			UpStairsType upStairsType = param_stairs.m_UpStairsType;
			Escalator.PlaceType placeType = param_stairs.m_PlaceType;
			bool bUpDownTurn = param_stairs.m_bUpDownTurn;
			int nRunCount = param_stairs.m_nRunCount;
			bool bNoteUpStairs = param_stairs.m_bNoteUpStairs;
			switch (nRunCount)
			{
			case 1:
			{
				SingleRunCurveInfo singleRunCurveInfo = new SingleRunCurveInfo();
				singleRunCurveInfo.BottomElevation = leftRunData.BottomElevation;
				base.DrawLinearRun(leftRunData, leftRunData.PtRunBottomLeft, leftRunData.PtRunBottomRight, leftRunData.PtRunTopRight, leftRunData.PtRunTopLeft, ref singleRunCurveInfo, ref param_stairs.m_listOtherCurve, bNoteUpStairs);
				param_stairs.m_listRunCurve.Add(singleRunCurveInfo);
				if (bUpDownTurn)
				{
					Escalator.Direction item = new Escalator.Direction(0, true);
					param_stairs.m_arDirection.Add(item);
					return;
				}
				Escalator.Direction item2 = new Escalator.Direction(0, false);
				param_stairs.m_arDirection.Add(item2);
				return;
			}
			case 2:
				this.DrawTwoRunCurves(ref param_stairs);
				return;
			case 3:
				this.DrawThreeRunCurves(ref param_stairs);
				return;
			case 4:
				this.DrawFourRunCurves(ref param_stairs);
				return;
			default:
				return;
			}
		}

		public bool EscalatorProfileCurves(ref Escalator stairs, bool bDrawNoteInfo, bool bDrawUpStairs, bool lrMirror, bool tbMirror, double rotateAngle)
		{
			bool result = true;
			int nIndexInsertPos = stairs.m_nIndexInsertPos;
			double bundingBoxWidth = 0.0;
			double bundingBoxHeight = 0.0;
			this.CalcStairsRunsOriginPoints(ref stairs);
			List<XYZ> list = this.CalcStairsInsertPoints(ref stairs, ref bundingBoxWidth, ref bundingBoxHeight, stairs.m_dFrontDepth, stairs.m_dTreadDepth, stairs.m_dStartDepth);
			XYZ xyz = list[nIndexInsertPos];
			base.CalulateTransform(lrMirror, tbMirror, rotateAngle, bundingBoxWidth, bundingBoxHeight, xyz);
			stairs.m_TransVector = Geometry.TransformPoint(xyz, this.m_Transform);
			stairs.m_listOtherCurve.AddRange(base.DrawBasePoint(xyz, 100.0));
			stairs.m_Transform = this.m_Transform;
			this.DrawEscalatorRunCurves(ref stairs);
			this.DrawEscalatorRectangelsCurves(ref stairs);
			XYZ xyz2 = XYZ.BasisY * 3.2;
			XYZ ptS = list[1] + xyz2;
			XYZ ptE = list[2] + xyz2;
			string sText = "扶梯总宽";
			Escalator.NoteData item = new Escalator.NoteData(ptS, ptE, sText, true);
			stairs.m_arNoteInfo.Add(item);
			if (bDrawUpStairs)
			{
				this.DrawEscalatorNoteInfo(ref stairs);
			}
			if (bDrawNoteInfo)
			{
				this.DrawUpStairsNoteInfo(ref stairs);
			}
			return result;
		}

		private double m_dRectWidth = Common.MMToFeet(100.0);

		private double m_dOffset = Common.MMToFeet(5.0);
	}
}
